package com.feng.nuike.huawei;

import com.sun.deploy.util.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author feng
 * @decrition
 * @date 2022/2/170:09
 */
public class HJ5 {
    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap();
        map.put("0", 0);
        map.put("1", 1);
        map.put("2", 2);
        map.put("3", 3);
        map.put("4", 4);
        map.put("5", 5);
        map.put("6", 6);
        map.put("7", 7);
        map.put("8", 8);
        map.put("9", 9);
        map.put("A", 10);
        map.put("B", 11);
        map.put("C", 12);
        map.put("D", 13);
        map.put("E", 14);
        map.put("F", 15);
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            if (s.startsWith("0x")) {
                int sum = 0;
                String substring = s.substring(2, s.length());
                StringBuilder sb = new StringBuilder(substring);
                StringBuilder reverse = sb.reverse();
                char[] chars = reverse.toString().toCharArray();
                for (int i = 0; i < chars.length; i++) {
                    Integer integer = map.get(chars[i] + "");
                    sum += Math.pow(16, i) * integer;
                }
                System.out.println(sum);
            }
        }
    }

}
